use tokio::task::AbortHandle;

pub(crate) struct SpawnedTasksClearGuard(Vec<AbortHandle>);

impl SpawnedTasksClearGuard {
    pub(crate) fn new() -> Self { Self(Vec::new()) }
    pub(crate) fn push(&mut self, handle: AbortHandle) { self.0.push(handle) }
}
impl Drop for SpawnedTasksClearGuard {
    fn drop(&mut self) {
        self.0.iter().for_each(AbortHandle::abort);
    }
}
